<?php 

class My_Loger extends Zend_Log {
	
	public function __construct($sendMail = false){
		parent::__construct();
		
        $this->addWriter(new Zend_Log_Writer_Firebug());
        !$sendMail || $this->addMailWriter();
	}
	
	private function addMailWriter(){
		// poczte można tworzyc niezaleznie - jeśli w ogóle
		$tr = new Zend_Mail_Transport_Smtp('zimbra.int.ccp.pl');
		Zend_Mail::setDefaultTransport($tr);
		$mail = new Zend_Mail('utf8');// złe kodowani? moze template/layout
		$mail->setFrom('timesheet@webtel.pl', 'System TS')
			->addTo('lk@webtel.pl', 'Administrator');
		$layout = new Zend_Layout(APPLICATION_PATH . '/views/scripts/');
		$layout->setLayout('mail_log_layout');
		$layoutFormatter = new Zend_Log_Formatter_Simple(// nie dumpuje obiektu exception
 		   '<li>' . Zend_Log_Formatter_Simple::DEFAULT_FORMAT . '</li>'
		);
		$writer = new Zend_Log_Writer_Mail($mail,$layout);
		$writer->setLayoutFormatter($layoutFormatter);
		$writer->setSubjectPrependText('Błąd aplikacji: ');
		$writer->addFilter(Zend_Log::DEBUG);
		$this->addWriter($writer);
	}

}
		 
?>